Release 10.1A: OpenEdge Data Management:
SQL Reference
FROM clause
Specifies one or more table references. Each table reference resolves to one table (either a table stored in the database or a virtual table resulting from processing the table reference) whose rows the query expression uses to create the result table.
Syntax
table_refThere are three forms of table references:
- A direct reference to a table, view, or synonym.
- A derived table specified by a query expression in the
FROMclause.- A joined table that combines rows and columns from multiple tables.
If there are multiple table references, SQL joins the tables to form an intermediate result table that is used as the basis for evaluating all other clauses in the query expression. That intermediate result table is the Cartesian product of rows in the tables in the
FROMclause, formed by concatenating every row of every table with all other rows in all tables, as shown in the following syntax:
FROM table_name [ AS ] [ alias [ ( column_alias [ ... ] ) ] ]Explicitly names a table. The name can be a table name, a view name, or a synonym.
aliasA name used to qualify column names in other parts of the query expression. Aliases are also called correlation names.
If you specify an alias, you must use it, and not the table name, to qualify column names that refer to the table. Query expressions that join a table with itself must use aliases to distinguish between references to column names.
Similar to table aliases, the column_alias provides an alternative name to use in column references elsewhere in the query expression. If you specify column aliases, you must specify them for all the columns in table_name. Also, if you specify column aliases in the
FROMclause, you must use them, and not the column names, in references to the columns.FROM ( query_expression ) [ AS ] [ alias [ ( column_alias [ ... ] ) ] ]Specifies a derived table through a query expression. With derived tables, you must specify an alias to identify the derived table.
Derived tables can also specify column aliases. Column aliases provide alternative names to use in column references elsewhere in the query expression. If you specify column aliases, you must specify them for all the columns in the result table of the query expression. Also, if you specify column aliases in the
FROMclause, you must use them, and not the column names, in references to the columns.FROM [ ( ] joined_table [ ) ]Combines data from two table references by specifying a join condition, as shown in the following syntax:
The syntax currently allowed in the
FROMclause supports only a subset of possible join conditions:
CROSSJOINspecifies a Cartesian product of rows in the two tables. Every row in one table is joined to every row in the other table.INNERJOINspecifies an inner join using the supplied search condition.LEFT OUTERJOINspecifies a left outer join using the supplied search condition.LEFT JOINspecifies the same conditions as an inner join.You can also specify these and other join conditions in the
WHEREclause of a query expression.{ NO REORDER }Disables join order optimization for the
ExampleFROMclause. UseNOREORDERwhen you choose to override the join order chosen by the optimizer. The braces are part of the syntax for this optional clause.For customers with orders, retrieve their names and order info, as shown in the following example:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |